#!/bin/bash
# only use this script file at deploy master host.
yum install -y wget
mv /etc/yum.repos.d/CentOS-Base.repo{,.bak}
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#删除阿里内网地址
sed -i '/aliyuncs.com/d' /etc/yum.repos.d/*.repo
yum clean all && yum makecache
yum update -y
yum install -y uuid git vim net-tools bash-completion chrony expect

# set ntp server
cp /etc/chrony.conf{,.bak}

sed -i 's/0.centos.pool.ntp.org/182.92.12.11/' /etc/chrony.conf
sed -i 's/1.centos.pool.ntp.org/cn.ntp.org.cn/' /etc/chrony.conf
sed -i 's/2.centos.pool.ntp.org/120.25.108.11/' /etc/chrony.conf
sed -i 's/3.centos.pool.ntp.org/ntp.aliyun.com/' /etc/chrony.conf

sed -i 's/^#\(local stratum 10\)/\1/' /etc/chrony.conf

systemctl start chronyd
systemctl enable chronyd

git clone https://gitee.com/antony-liu/openstack-deploy

cd ./openstack-deploy/scripts

mkdir -p /var/www/openstack/scripts
/usr/bin/cp -f *.sh /var/www/openstack/scripts/
chmod +x *.sh
/usr/bin/cp -f host.sample hosts

echo "Alias /openstack \"/var/www/openstack\"
<Directory \"/var/www/openstack\">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
#    Deny from all
    Allow from all
    Require all granted
</Directory>
">/etc/httpd/conf.d/openstack.conf

systemctl restart httpd
systemctl enable httpd

reboot